MkCliDoc
:fa-brands-github: Show source on GitHub
Node for showing documentation for click / typer CLI apps.¶
Example: MkDocs-MkNodes CLI¶
mknodes¶
MkNodes: build documentation from Python node trees.
generate writes the pages (and the site config), build / serve also run the site engine. Docs: https://phil65.github.io/mknodes/
--install-completion¶
:mdi-flag: Flag Install completion for the current shell.
--show-completion¶
:mdi-flag: Flag Show completion for the current shell, to copy it or customize the installation.
--help¶
:mdi-flag: Flag Show this message and exit.
## mknodes
MkNodes: build documentation from Python node trees.
`generate` writes the pages (and the site config), `build` / `serve` also run the site engine. Docs: https://phil65.github.io/mknodes/
```` {.python }
mknodes [OPTIONS] COMMAND [ARGS]...
````
### `--install-completion`
<span class="md-typeset mdx-badge">
<span class="mdx-badge__icon">:mdi-flag:</span>
<span class="mdx-badge__text">Flag</span>
</span>
Install completion for the current shell.
### `--show-completion`
<span class="md-typeset mdx-badge">
<span class="mdx-badge__icon">:mdi-flag:</span>
<span class="mdx-badge__text">Flag</span>
</span>
Show completion for the current shell, to copy it or customize the installation.
### `--help`
<span class="md-typeset mdx-badge">
<span class="mdx-badge__icon">:mdi-flag:</span>
<span class="mdx-badge__text">Flag</span>
</span>
Show this message and exit.
<h2 id="mknodes">mknodes</h2>
<p>MkNodes: build documentation from Python node trees.</p>
<p><code>generate</code> writes the pages (and the site config), <code>build</code> / <code>serve</code> also run the site engine. Docs: <a href="https://phil65.github.io/mknodes/">https://phil65.github.io/mknodes/</a></p>
<div class="language-python highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">mknodes</span> <span class="p">[</span><span class="n">OPTIONS</span><span class="p">]</span> <span class="n">COMMAND</span> <span class="p">[</span><span class="n">ARGS</span><span class="p">]</span><span class="o">...</span>
</span></code></pre></div>
<h3 id="-install-completion"><code>--install-completion</code></h3>
<p><span class="md-typeset mdx-badge">
<span class="mdx-badge__icon"><span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/></svg></span></span>
<span class="mdx-badge__text">Flag</span>
</span>
Install completion for the current shell.</p>
<h3 id="-show-completion"><code>--show-completion</code></h3>
<p><span class="md-typeset mdx-badge">
<span class="mdx-badge__icon"><span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/></svg></span></span>
<span class="mdx-badge__text">Flag</span>
</span>
Show completion for the current shell, to copy it or customize the installation.</p>
<h3 id="-help"><code>--help</code></h3>
<p><span class="md-typeset mdx-badge">
<span class="mdx-badge__icon"><span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/></svg></span></span>
<span class="mdx-badge__text">Flag</span>
</span>
Show this message and exit.</p>
MkCliDoc
├── MkHeader('mknodes')
├── MkCode(None)
│ ╰── MkText('mknodes [OPTIONS] COMMAND [ARGS]...')
╰── MkHeader('`--install-completion`', level=3)
├── MkMaterialBadge('mdi:flag', 'Flag')
╰── MkHeader('`--show-completion`', level=3)
├── MkMaterialBadge('mdi:flag', 'Flag')
╰── MkHeader('`--help`', level=3)
╰── MkMaterialBadge('mdi:flag', 'Flag')
Example: SubCommand¶
build¶
Build a MkNodes-based website, locally or remotely.
Runs the build function on given repository (either locally or a hosted one),
writes the generated pages and config (see generate) and builds the HTML website
with the engine (zensical build -f <generated config>, mkdocs build -f ...,
mdbook build <book dir>, sphinx-build <source dir> <site dir>). Docsify has no
build step: the generated site dir is the website.
Problems which leave pages broken (build diagnostics) get logged as warnings and summarized at the end; in strict mode they fail the build.
Further info here: https://phil65.github.io/mknodes/CLI/
--repo-url, -r¶
Repository URL of the target package. Can be remote or local.
--build-fn, -b¶
Path to the build script. (form: path.to.module:function )
--site-dir, -d¶
Path to the folder where the HTML should get written.
--clone-depth, -c¶
Git clone depth in case repository is remote. Important for changelog generation.
--config-path, -p¶
Default: mkdocs.yml Path to the config file.
--strict, -s¶
:mdi-flag:
Flag
Strict mode: fail if the build reported problems (failed nodes, /// mknodes or python exec blocks, broken code fences, unresolved references). Also passed to the engine. Default: the strict setting.
--engine, -e¶
Default: zensical
Site engine: zensical (HTML site, default), mkdocs (HTML site, needs the mkdocs extra), mdbook (HTML book, needs the mdbook binary to build / serve), sphinx (HTML site from MyST Markdown, needs the sphinx extra), docsify (Markdown rendered in the browser, no build step) or markdown (plain Markdown files).
--flavor¶
Markdown flavour (material, github, mdbook, myst). Default: the engine's flavour (zensical / mkdocs: material, mdbook: mdbook, sphinx: myst, docsify / markdown: github).
--jinja-engine¶
Template engine for the Jinja templates: jinja2 (default) or minijinja (needs the minijinja extra). Default: jinja_engine of [tool.mknodes], else the MKNODES_JINJA_ENGINE environment variable, else jinja2.
--offline¶
:mdi-flag:
Flag
Take external inputs (icons, licenses, LLM texts) only from the lock file (mknodes.lock): fail if one is missing, never write the lock file.
--refresh-inputs¶
:mdi-flag: Flag Fetch all external inputs again and rewrite the lock file with exactly the used ones.
--verbose, -v¶
:mdi-flag:
Flag
Enable verbose output. (DEBUG level)
--quiet, -q¶
:mdi-flag: Flag Suppress output.
--help¶
:mdi-flag: Flag Show this message and exit.
## build
Build a MkNodes-based website, locally or remotely.
Runs the build function on given repository (either locally or a hosted one),
writes the generated pages and config (see `generate`) and builds the HTML website
with the engine (`zensical build -f <generated config>`, `mkdocs build -f ...`,
`mdbook build <book dir>`, `sphinx-build <source dir> <site dir>`). Docsify has no
build step: the generated site dir is the website.
Problems which leave pages broken (build diagnostics) get logged as warnings and
summarized at the end; in strict mode they fail the build.
Further info here: https://phil65.github.io/mknodes/CLI/
```` {.python }
mknodes build [OPTIONS]
````
### `--repo-url`, `-r`
Repository URL of the target package. Can be remote or local.
### `--build-fn`, `-b`
Path to the build script. (form: `path.to.module:function` )
### `--site-dir`, `-d`
Path to the folder where the HTML should get written.
### `--clone-depth`, `-c`
Git clone depth in case repository is remote. Important for changelog generation.
### `--config-path`, `-p`
**Default:** mkdocs.yml
Path to the config file.
### `--strict`, `-s`
<span class="md-typeset mdx-badge">
<span class="mdx-badge__icon">:mdi-flag:</span>
<span class="mdx-badge__text">Flag</span>
</span>
Strict mode: fail if the build reported problems (failed nodes, `/// mknodes` or `python exec` blocks, broken code fences, unresolved references). Also passed to the engine. Default: the `strict` setting.
### `--engine`, `-e`
**Default:** zensical
Site engine: `zensical` (HTML site, default), `mkdocs` (HTML site, needs the `mkdocs` extra), `mdbook` (HTML book, needs the `mdbook` binary to build / serve), `sphinx` (HTML site from MyST Markdown, needs the `sphinx` extra), `docsify` (Markdown rendered in the browser, no build step) or `markdown` (plain Markdown files).
### `--flavor`
Markdown flavour (`material`, `github`, `mdbook`, `myst`). Default: the engine's flavour (zensical / mkdocs: `material`, mdbook: `mdbook`, sphinx: `myst`, docsify / markdown: `github`).
### `--jinja-engine`
Template engine for the Jinja templates: `jinja2` (default) or `minijinja` (needs the `minijinja` extra). Default: `jinja_engine` of [tool.mknodes], else the MKNODES_JINJA_ENGINE environment variable, else jinja2.
### `--offline`
<span class="md-typeset mdx-badge">
<span class="mdx-badge__icon">:mdi-flag:</span>
<span class="mdx-badge__text">Flag</span>
</span>
Take external inputs (icons, licenses, LLM texts) only from the lock file (`mknodes.lock`): fail if one is missing, never write the lock file.
### `--refresh-inputs`
<span class="md-typeset mdx-badge">
<span class="mdx-badge__icon">:mdi-flag:</span>
<span class="mdx-badge__text">Flag</span>
</span>
Fetch all external inputs again and rewrite the lock file with exactly the used ones.
### `--verbose`, `-v`
<span class="md-typeset mdx-badge">
<span class="mdx-badge__icon">:mdi-flag:</span>
<span class="mdx-badge__text">Flag</span>
</span>
Enable verbose output. (`DEBUG` level)
### `--quiet`, `-q`
<span class="md-typeset mdx-badge">
<span class="mdx-badge__icon">:mdi-flag:</span>
<span class="mdx-badge__text">Flag</span>
</span>
Suppress output.
### `--help`
<span class="md-typeset mdx-badge">
<span class="mdx-badge__icon">:mdi-flag:</span>
<span class="mdx-badge__text">Flag</span>
</span>
Show this message and exit.
<h2 id="build">build</h2>
<p>Build a MkNodes-based website, locally or remotely.</p>
<p>Runs the build function on given repository (either locally or a hosted one),
writes the generated pages and config (see <code>generate</code>) and builds the HTML website
with the engine (<code>zensical build -f <generated config></code>, <code>mkdocs build -f ...</code>,
<code>mdbook build <book dir></code>, <code>sphinx-build <source dir> <site dir></code>). Docsify has no
build step: the generated site dir is the website.</p>
<p>Problems which leave pages broken (build diagnostics) get logged as warnings and
summarized at the end; in strict mode they fail the build.</p>
<p>Further info here: <a href="https://phil65.github.io/mknodes/CLI/">https://phil65.github.io/mknodes/CLI/</a></p>
<div class="language-python highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">mknodes</span> <span class="n">build</span> <span class="p">[</span><span class="n">OPTIONS</span><span class="p">]</span>
</span></code></pre></div>
<h3 id="-repo-url-r"><code>--repo-url</code>, <code>-r</code></h3>
<p>Repository URL of the target package. Can be remote or local.</p>
<h3 id="-build-fn-b"><code>--build-fn</code>, <code>-b</code></h3>
<p>Path to the build script. (form: <code>path.to.module:function</code> )</p>
<h3 id="-site-dir-d"><code>--site-dir</code>, <code>-d</code></h3>
<p>Path to the folder where the HTML should get written.</p>
<h3 id="-clone-depth-c"><code>--clone-depth</code>, <code>-c</code></h3>
<p>Git clone depth in case repository is remote. Important for changelog generation.</p>
<h3 id="-config-path-p"><code>--config-path</code>, <code>-p</code></h3>
<p><strong>Default:</strong> mkdocs.yml
Path to the config file.</p>
<h3 id="-strict-s"><code>--strict</code>, <code>-s</code></h3>
<p><span class="md-typeset mdx-badge">
<span class="mdx-badge__icon"><span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/></svg></span></span>
<span class="mdx-badge__text">Flag</span>
</span>
Strict mode: fail if the build reported problems (failed nodes, <code>/// mknodes</code> or <code>python exec</code> blocks, broken code fences, unresolved references). Also passed to the engine. Default: the <code>strict</code> setting.</p>
<h3 id="-engine-e"><code>--engine</code>, <code>-e</code></h3>
<p><strong>Default:</strong> zensical
Site engine: <code>zensical</code> (HTML site, default), <code>mkdocs</code> (HTML site, needs the <code>mkdocs</code> extra), <code>mdbook</code> (HTML book, needs the <code>mdbook</code> binary to build / serve), <code>sphinx</code> (HTML site from MyST Markdown, needs the <code>sphinx</code> extra), <code>docsify</code> (Markdown rendered in the browser, no build step) or <code>markdown</code> (plain Markdown files).</p>
<h3 id="-flavor"><code>--flavor</code></h3>
<p>Markdown flavour (<code>material</code>, <code>github</code>, <code>mdbook</code>, <code>myst</code>). Default: the engine's flavour (zensical / mkdocs: <code>material</code>, mdbook: <code>mdbook</code>, sphinx: <code>myst</code>, docsify / markdown: <code>github</code>).</p>
<h3 id="-jinja-engine"><code>--jinja-engine</code></h3>
<p>Template engine for the Jinja templates: <code>jinja2</code> (default) or <code>minijinja</code> (needs the <code>minijinja</code> extra). Default: <code>jinja_engine</code> of [tool.mknodes], else the MKNODES_JINJA_ENGINE environment variable, else jinja2.</p>
<h3 id="-offline"><code>--offline</code></h3>
<p><span class="md-typeset mdx-badge">
<span class="mdx-badge__icon"><span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/></svg></span></span>
<span class="mdx-badge__text">Flag</span>
</span>
Take external inputs (icons, licenses, LLM texts) only from the lock file (<code>mknodes.lock</code>): fail if one is missing, never write the lock file.</p>
<h3 id="-refresh-inputs"><code>--refresh-inputs</code></h3>
<p><span class="md-typeset mdx-badge">
<span class="mdx-badge__icon"><span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/></svg></span></span>
<span class="mdx-badge__text">Flag</span>
</span>
Fetch all external inputs again and rewrite the lock file with exactly the used ones.</p>
<h3 id="-verbose-v"><code>--verbose</code>, <code>-v</code></h3>
<p><span class="md-typeset mdx-badge">
<span class="mdx-badge__icon"><span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/></svg></span></span>
<span class="mdx-badge__text">Flag</span>
</span>
Enable verbose output. (<code>DEBUG</code> level)</p>
<h3 id="-quiet-q"><code>--quiet</code>, <code>-q</code></h3>
<p><span class="md-typeset mdx-badge">
<span class="mdx-badge__icon"><span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/></svg></span></span>
<span class="mdx-badge__text">Flag</span>
</span>
Suppress output.</p>
<h3 id="-help"><code>--help</code></h3>
<p><span class="md-typeset mdx-badge">
<span class="mdx-badge__icon"><span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/></svg></span></span>
<span class="mdx-badge__text">Flag</span>
</span>
Show this message and exit.</p>
MkCliDoc
├── MkHeader('build')
├── MkCode(None)
│ ╰── MkText('mknodes build [OPTIONS]')
├── MkHeader('`--repo-url`, `-r`', level=3)
├── MkHeader('`--build-fn`, `-b`', level=3)
├── MkHeader('`--site-dir`, `-d`', level=3)
├── MkHeader('`--clone-depth`, `-c`', level=3)
├── MkHeader('`--config-path`, `-p`', level=3)
╰── MkHeader('`--strict`, `-s`', level=3)
├── MkMaterialBadge('mdi:flag', 'Flag')
├── MkHeader('`--engine`, `-e`', level=3)
├── MkHeader('`--flavor`', level=3)
├── MkHeader('`--jinja-engine`', level=3)
╰── MkHeader('`--offline`', level=3)
├── MkMaterialBadge('mdi:flag', 'Flag')
╰── MkHeader('`--refresh-inputs`', level=3)
├── MkMaterialBadge('mdi:flag', 'Flag')
╰── MkHeader('`--verbose`, `-v`', level=3)
├── MkMaterialBadge('mdi:flag', 'Flag')
╰── MkHeader('`--quiet`, `-q`', level=3)
├── MkMaterialBadge('mdi:flag', 'Flag')
╰── MkHeader('`--help`', level=3)
╰── MkMaterialBadge('mdi:flag', 'Flag')
Bases: MkTemplate
__init__
¶
__init__(
target: str | ArgumentParser | None = None,
*,
prog_name: str | None = None,
show_hidden: bool = False,
show_subcommands: bool = False,
**kwargs: Any
) -> None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str | ArgumentParser | None
|
Dotted path to click group / typer instance / ArgumentParser |
None
|
prog_name
|
str | None
|
Program name |
None
|
show_hidden
|
bool
|
Show commands and options that are marked as hidden. |
False
|
show_subcommands
|
bool
|
List subcommands of a given command. |
False
|
kwargs
|
Any
|
Keyword arguments passed to parent |
{}
|
| Name | Children | Inherits |
|---|---|---|
| MkTemplate mknodes.templatenodes.mktemplate Node representing a jinja template. |
graph TD
3586431358["mkclidoc.MkCliDoc"]
1289759389["mktemplate.MkTemplate"]
3160803176["rendercache.TemplateRenderMixin"]
2751680898["builtins.object"]
835538629["mkcontainer.MkContainer"]
1956333208["mkcontainer.MkContainerBase"]
1359323199["mknode.MkNode"]
1289759389 --> 3586431358
3160803176 --> 1289759389
2751680898 --> 3160803176
835538629 --> 1289759389
1956333208 --> 835538629
1359323199 --> 1956333208
2751680898 --> 1359323199
[metadata]
icon = "mdi:api"
name = "MkCliDoc"
[examples.cli]
title = "MkDocs-MkNodes CLI"
jinja = """
{{ "mknodes.cli:cli" | MkCliDoc }}
"""
[examples.sub_command]
title = "SubCommand"
jinja = """
{{ "mknodes.cli:cli" | MkCliDoc(prog_name="build") }}
"""
[examples.argparse]
title = "ArgumentParser"
python = """
import git_changelog
import mknodes as mk
parser = git_changelog.get_parser()
mk.MkCliDoc(parser)
"""
[fragments]
param_template = """
{{ param.opt_str | MkHeader(level=3) }}
{% if param.required %}
"{{ "REQUIRED" | md_style(bold=True) }}"
{% endif %}
{% if param.envvar %}
Environment variable{{ param.envvar }}
{% endif %}
{% if param.multiple %}
{{ "Multiple values allowed." | md_style(bold=True) }}
{% endif %}
{% if param.default %}
{{ "Default:" | md_style(bold=True) }} {{ param.default }}
{% endif %}
{% if param.is_flag %}
{{ "mdi:flag" | MkMaterialBadge("Flag") }}
{% endif %}
{% if param.help %}
{{ param.help }}
{% endif %}
"""
command_template = """
{{ info.name | MkHeader }}
{{ info.description }}
{{ info.usage | MkCode }}
{% for param in info.params %}
{{ "fragments/param_template" | render_template(param=param) }}
{% endfor %}
"""
[output.markdown]
template = """
{% if node.info %}
{{ "fragments/command_template" | render_template(info=node.info) }}
{% if node.show_subcommands %}
{% for sub_info in node.info.subcommands.values() %}
{{ "fragments/command_template" | render_template(info=sub_info) }}
{% endfor %}
{% endif %}
{% endif %}
"""